<template>
  <div class="dashboard-container">
    <div class="dashboard-text">欢迎~ {{ myname }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import studentApi from '@/api/stu';
import { getStudentId, setStudentId } from '@/utils/auth';

export default {
  name: 'Dashboard',
  userId:"",
  computed: {
    ...mapGetters([
      'name',
      'userId'
    ])
  },
  data(){
    return{
      myname:""
    }
  },
  methods:{
    getStudentInfo(){
      studentApi.getStudentByUserId(this.userId).then(response =>{
        if (response.code == 20000) {
          setStudentId(response.data.id);
          this.myname = response.data.name;
        }
      })
    }
  },
  created() {
    this.getStudentInfo();
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
  
}
</style>
